package com.gary.vueblog.entity;

import lombok.*;

import java.io.Serializable;

/**
 * @author pengrui
 * @date 2020/12/8 - 10:51
 */
@Getter
@Setter
@ToString
@Builder
public class ResultInfo implements Serializable {
    private static final long serialVersionUID = 230854467592065178L;
    /**
     *  信息码
     *  200 300 400 500
     */
    private Integer code;

    /**
     * 信息
     */
    private String msg;

    /**
     *  返回数据
     */
    private Object data;

    /**
     *  无参构造
     */
    private ResultInfo(){}

    private ResultInfo(Integer code, String msg, Object data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    /**
     *  返回方法
     * @param code
     * @param msg
     * @param data
     * @return
     */
    public static ResultInfo res(Integer code, String msg, Object data) {
        return new ResultInfo(code, msg, data);
    }

    /**
     *  成功返回
     * @param data
     * @return
     */
    public static ResultInfo success(Object data) {
        return res(200, "请求成功", data);
    }
}
